﻿using System.ComponentModel;
using WickedFlame.Core;

namespace WickedFlame.Util
{
    public class VectorImage : INotifyPropertyChanged
    {
        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void NotifyPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }

        #endregion

        string fileName = "";
        public string FileName
        {
            get
            {
                return fileName;
            }
            set
            {
                fileName = value;
                NotifyPropertyChanged("FileName");
            }
        }

        string path;
        public string Path
        {
            get
            {
                return path;
            }
            set
            {
                path = value;
                NotifyPropertyChanged("Path");
            }
        }

        public bool IsDirty
        {
            get
            {
                return DrawingCanvas.IsDirty;
            }
			set
			{
				DrawingCanvas.IsDirty = value;
				NotifyPropertyChanged("IsDirty");
				IsUnwrittenCanvas = false;
			}
        }

        bool isUnwrittenCanvas = true;
        public bool IsUnwrittenCanvas
        {
            get
            {
                return isUnwrittenCanvas;
            }
            set
            {
                isUnwrittenCanvas = value;
                NotifyPropertyChanged("IsUnwrittenCanvas");
            }
        }

        DrawingCanvas drawingCanvas;
        public DrawingCanvas DrawingCanvas
        {
            get
            {
                return drawingCanvas;
            }
            set
            {
                drawingCanvas = value;
                NotifyPropertyChanged("DrawingCanvas");
				drawingCanvas.DirtyChanged += new System.EventHandler(DirtyChanged);
            }
        }

		void DirtyChanged(object sender, System.EventArgs e)
		{
			//IsDirty = DrawingCanvas.IsDirty;
			IsUnwrittenCanvas = false;
			NotifyPropertyChanged("IsDirty");
		}
    }
}
